package bluerain.io.activity.ui;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import bluerain.io.activity.entries.Person;

/**
 * Created by foredawn on 15-9-11.
 * 供LauncherActivity启动的Activity
 */
public class GetResultActivity extends Activity {
    TextView text;
    Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout linear = new LinearLayout(GetResultActivity.this);
        linear.setOrientation(LinearLayout.VERTICAL);
        btn = new Button(this);
        btn.setText("设置用户信息");
        text = new TextView(this);
        linear.addView(btn);
        linear.addView(text);
        setContentView(linear);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(GetResultActivity.this, RegisterActivityTest.class), 0);
            }
        });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && resultCode == 0) { //请求和结果码为0
            Person person = (Person) data.getSerializableExtra("person");
            text.setText(person.toString());
        }
    }
}
